<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

    <div id="app">
        <p>
            id: <input type="text" v-model="bookId">
            title: <input type="text" v-model="title">
            <button @click="add">添加</button>
        </p>

        <p v-for="(book,index) in books" :key="book.id">
            <input type="checkbox">
            <span>ID: {{book.id}}，书名是：{{book.title}}</span>
        </p>

    </div>

    <script src="js/vue.global.js"></script>
    <script>
        var vm = Vue.createApp({
            data(){
                return {
                    searchText:"ok",
                    bookId:"",
                    title:"",
                    books:[
                        {id:1,title:"Java无难事"},
                        {id:2,title:"VC++深入详解"},
                        {id:3,title:"Servlet/JSP深入详解"}
                    ]
                }
            },
            methods:{
                add(){
                    this.books.unshift({id:this.bookId,title:this.title});
                    this.title = "";
                    this.bookId = "";
                }
            }
        }).mount("#app");
    </script>

</body>
</html>